/*
* 存储密钥
* */
export default {
    namespaced: true,
    state: {
        // aes密钥ID
        encryptionID:"",
        // 公钥
        publickey:"",
        // aes密钥
        aeskey:"",
        // AES密钥刷新时间间隔,一个小时
        refreshtime:3600*1000,
    },
    mutations:{
        // 修改数据
        getkey(State,payload){
            State.encryptionID = payload.id
            State.publickey = payload.publickey
            State.aeskey = payload.id.slice(0,16)
        },
        // 重置数据
        reststate(State){
            State.encryptionID = ""
            State.publickey = ""
            State.aeskey = ""
        }
    },
    actions:{
        // 接收公钥
        encryption(content,payload){
            content.commit("getkey",payload)
            setInterval(()=>{
                content.dispatch("refreshAES")
            },content.state.refreshtime)
        },
        // 刷新AES密钥
        refreshAES(content,payload){
            console.log("刷新aes密钥")
        }
    },
}



